<template>
  <n-layout has-sider>
    <n-layout-sider bordered content-style="padding: 24px;">
      <n-menu @update:value="handleUpdateValue" :options="menuOptions" />
    </n-layout-sider>
    <n-layout>
      <n-layout-content content-style="padding: 24px;">
        <router-view></router-view>
      </n-layout-content>
    </n-layout>
  </n-layout>
</template>

<script>
import { h, resolveComponent } from "vue";
import { HomeOutline as HomeIcon } from "@vicons/ionicons5";
import { NIcon } from "naive-ui";

function renderIcon(icon) {
  return () => h(NIcon, null, { default: () => h(icon) });
}
const menuOptions = [
  {
    label: () =>
      h(
        resolveComponent("router-link"),
        {
          to: "/singleFileUpload",
        },
        { default: () => "单文件传输" }
      ),
    key: "single-file-upload",
    icon: renderIcon(HomeIcon),
  },
  {
    label: () =>
      h(
        resolveComponent("router-link"),
        {
          to: "/fileSliceUpload",
        },
        { default: () => "文件分片传输" }
      ),
    key: "slice-file-upload",
    icon: renderIcon(HomeIcon),
  },
];

export default {
  name: "App",
  components: {},
  setup() {
    return {
      menuOptions,
      handleUpdateValue(key, item) {
        console.log(key, item);
      },
    };
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
